package com.hongxun.design.ui.photographview;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.List;

import com.hongxun.design.R;
import com.hongxun.design.activitys.EditImageActivity;
import com.hongxun.design.adapters.PEnvironmentalAdapter;
import com.hongxun.design.bean.PhotoEnvironmentalItemBean;
import com.hongxun.design.mytools.MyLog;
import com.hongxun.design.mytools.SetTypeface;
import com.hongxun.design.ui.ui_listview.NotScrollList;

/**
 * Created by zerdoor_pc on 2016/5/13.
 */
public class PhotoEnvironmentalDialog extends LinearLayout implements View.OnTouchListener {
    public NotScrollList listview;
    public PhotoEnvironmentalDialog(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    RelativeLayout body;
    TextView title, right, reset, preservation;

    @Override
    protected void onFinishInflate() {
        /**标题部分**/
//        RelativeLayout environmental_head = (RelativeLayout) findViewById(R.id.environmental_head);//标题按钮控制显隐
//        title = (TextView) findViewById(R.id.environmental_title);//标题
//        right = (TextView) findViewById(R.id.environmental_right);//右方按钮
//        SetTypeface.set(right, IconSourse.DROPDOWN);
        /**正文部分**/
        listview = (NotScrollList) findViewById(R.id.environmental_listview);
//        reset = (TextView) findViewById(R.id.environmental_reset);//重置
//        preservation = (TextView) findViewById(R.id.environmental_preservation);//保存
//        body = (RelativeLayout) findViewById(R.id.environmental_body);//主要部分
//
//        environmental_head.setOnClickListener(new OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                if (body.getVisibility() == VISIBLE) {
//                    body.setVisibility(GONE);
//                } else {
//                    body.setVisibility(VISIBLE);
//                }
//            }
//        });
        super.onFinishInflate();
    }

    public void setTitle(String title) {
        this.title.setText(title);
    }

    public void setRight(String icon) {
        SetTypeface.set(right, icon);
    }
    Activity context;
    public PEnvironmentalAdapter setListview(List<PhotoEnvironmentalItemBean> Bean, Activity context) {

        if (listview == null) {
            listview = (NotScrollList) findViewById(R.id.environmental_listview);
        }
        this.context=context;
//        ArrayList<String> myStringArray = new ArrayList<String>();
//        myStringArray.add("1");
//        myStringArray.add("2");
//        myStringArray.add("3");
//        myStringArray.add("4");
//        ArrayAdapter<String> myAdapterInstance;
//
//        int layoutID = android.R.layout.simple_list_item_1;
//
//        myAdapterInstance = new ArrayAdapter<String>(context, layoutID, myStringArray);
//
//        listview.setAdapter(myAdapterInstance);
//        listview.setAdapter();
        PEnvironmentalAdapter adapter = new PEnvironmentalAdapter(Bean,   context);

//        CreateProjectAdapter adapter1=new CreateProjectAdapter(DataUtil.getCreateItemData(),context);
        listview.setAdapter(adapter);
        listview.setOnTouchListener(this);
        return adapter;
    }

    public void setReset(OnClickListener listener) {
        reset.setOnClickListener(listener);
    }

    public void setPreservation(OnClickListener listener) {
        preservation.setOnClickListener(listener);
    }


    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        MyLog.L("listdatalistdatalistdata:onTouch1");
                ((EditImageActivity) context).onTouch(view, motionEvent);
        return false;
    }
}
